<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>数据源模板</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body>

<script type="text/html" id="headerToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <a class="layui-btn layui-btn-sm" lay-event="query">
                <i class="layui-icon layui-icon-search"></i>
                <span>查询</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="add">
                <i class="layui-icon layui-icon-add-1"></i>
                <span>添加</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="reset">
                <i class="layui-icon layui-icon-refresh"></i>
                <span>重置</span>
            </a>
        </div>
        <form class="layui-form" action="" style="margin-top:10px" lay-filter="dataSourceDef">
            <div class="table-top-filter">
                <div class="table-filter-alone">
                    <label class="layui-form-label">名称 </label>
                    <input type="text" name="Q_name_SL" id="name" class="layui-input filter-value" placeholder="名称"
                           autocomplete="off"/>
                </div>
                <div class="table-filter-alone">
                    <label class="layui-form-label">类路径</label>
                    <input type="text" name="Q_classPath_SL" id="classPath" class="layui-input filter-value" placeholder="类路径"
                           autocomplete="off"/>
                </div>
            </div>
        </form>
    </div>
</script>
<div class="ccpui-tablesize formView" style="padding:10px;">
<table class="layui-hide" id="sourceDef" lay-filter="sourceDef"></table>
</div>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','table', 'layer', 'jquery', 'form','totalFilter','common','commons'], function () {
        var table = layui.table, layer = layui.layer, $ = layui.$,form = layui.form,setter = layui.setter,
            totalFilter=layui.totalFilter,common=layui.common,commons=layui.commons
        var tableH='full-70';
        var tableH=commons.tabHeight(tableH);
        common.tableSort("sourceDef");
        table.render({
            elem: '#sourceDef'
            ,height: tableH
            ,defaultToolbar:[]
            , url: serverPath.systemPath + setter.sysLinkPath + 'dataSourceDef/list'
            , toolbar: '#headerToolsBar'
            , title: '数据源模板表'
            , autoSort: false
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'name', title: '名称', sort:true,align: 'center'}
                , {field: 'classPath', title: '类路径', align: 'center'}
                , {
                    field: 'system', title: '系统默认', align: 'center',
                    templet: function (d) {
                        if (d.system == 1) {
                            return '是';
                        }
                        return '否';
                    }
                }
                , {fixed: 'right', title: '管理', toolbar: '#barDemo', width: 150, align: 'center'}
            ]]
            , page: true,
            done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
            }
        });
        //初始化条件查询
        totalFilter.init('sourceDef');
        //头工具栏事件
        table.on('toolbar(sourceDef)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data; //获取选中行数据
            switch (obj.event) {
                case 'add':
                    layer.open({
                        type: 2,
                        title: "添加",
                        shade: 0.3,
                        left: 200,
                        area: ['750px', '600px'],
                        content: serverPath.systemPath + setter.sysLinkPath +'dataSourceDef/view/addEdit'
                    });
                    break;
                case 'query':
                    common.tableConditionRender("sourceDef","dataSourceDef",{where:{}},false);
                    break;
                case 'reset':
                    common.tableConditionRender("sourceDef","dataSourceDef",{where:{}},true);
                    break;
            }
        });

        //监听行工具事件
        table.on('tool(sourceDef)', function (obj) {
            var data = obj.data;
            var tableId = {"id": data.id};
            switch (obj.event) {
                case 'del':
                    layer.confirm('确定删除当前数据吗？', function () {
                        $.ajax({
                            url: serverPath.systemPath + setter.sysLinkPath + 'dataSourceDef/del',
                            dataType: 'json',
                            data: tableId,
                            success: function (data) {
                                //提示消息
                                layer.alert(data.msg);
                                //执行重载
                                table.reload('sourceDef', {
                                    page: {
                                        curr: 1
                                    }
                                });
                                totalFilter.init('sourceDef');
                            }
                        })
                    });
                    break;
                case 'edit':
                    var oid = obj.data.id;
                    layer.open({
                        type: 2
                        , title: "编辑"
                        , area: ['750px', '570px']
                        , content: serverPath.systemPath + setter.sysLinkPath +'dataSourceDef/view/addEdit?defId=' + oid
                    });
                    break;
            }
        });
    });
</script>
</body>
</html>
<link rel="stylesheet" href="${ctx}/css/font/iconfontie.css" media="all"/>
<link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>